<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class MyStage extends Model
{
    protected $table='park_mystage';
    protected $guarded=[];
    protected $primaryKey='ID';
    public $timestamps=false;
    
    protected static function boot()
    {
        parent::boot();
    
        //效果未失效
        static::addGlobalScope('status', function(Builder $builder) {
            $builder->where('status', 0);
        });
        
    }
    
    //未对车使用过
    public function scopeUnused($query)
    {
        return $query->where('car_id', 0);
    }
    
    public function stage()
    {
        return $this->belongsTo(Stage::class,'StageID','StageID');
    }
}
